﻿using Autofac;
using Autofac.Integration.Mvc;
using PracticeCentre.Mvc.Core.Authentication;
using PracticeCentre.Mvc.Core.Engines;
using PracticeCentre.Mvc.Core.Logging;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace PracticeCentre.Mvc
{
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            var builder = new ContainerBuilder();
            builder.RegisterType<AspFormsAuthentication>().As<IFormsAuthentication>().InstancePerLifetimeScope();
            
            builder.RegisterType<Log4NetAdapter>().As<ILogger>().InstancePerLifetimeScope();            
            var container = builder.Build();
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
            EngineContainerFactory.InitializeEngineContainerFactory(new EngineContainer(container));
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }
    }
}
